package com.loan.web.pdf.controller.create;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.loan.common.annotation.Log;
import com.loan.common.core.controller.BaseController;
import com.loan.common.core.domain.AjaxResult;
import com.loan.common.enums.BusinessType;
import com.loan.system.create.domain.AssistPdfSearchBase;
import com.loan.system.create.service.IAssistPdfSearchBaseService;
import com.loan.common.utils.poi.ExcelUtil;
import com.loan.common.core.page.TableDataInfo;

/**
 * 检索数据Controller
 * 
 * @author Sophia
 * @date 2024-07-06
 */
@RestController
@RequestMapping("/system/search")
public class AssistPdfSearchBaseController extends BaseController
{
    @Autowired
    private IAssistPdfSearchBaseService assistPdfSearchBaseService;

    /**
     * 查询检索数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:search:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssistPdfSearchBase assistPdfSearchBase)
    {
        startPage();
        List<AssistPdfSearchBase> list = assistPdfSearchBaseService.selectAssistPdfSearchBaseList(assistPdfSearchBase);
        return getDataTable(list);
    }

    /**
     * 导出检索数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:search:export')")
    @Log(title = "检索数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssistPdfSearchBase assistPdfSearchBase)
    {
        List<AssistPdfSearchBase> list = assistPdfSearchBaseService.selectAssistPdfSearchBaseList(assistPdfSearchBase);
        ExcelUtil<AssistPdfSearchBase> util = new ExcelUtil<AssistPdfSearchBase>(AssistPdfSearchBase.class);
        util.exportExcel(response, list, "检索数据数据");
    }

    /**
     * 获取检索数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:search:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assistPdfSearchBaseService.selectAssistPdfSearchBaseById(id));
    }

    /**
     * 新增检索数据
     */
    @PreAuthorize("@ss.hasPermi('system:search:add')")
    @Log(title = "检索数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssistPdfSearchBase assistPdfSearchBase)
    {
        return toAjax(assistPdfSearchBaseService.insertAssistPdfSearchBase(assistPdfSearchBase));
    }

    /**
     * 修改检索数据
     */
    @PreAuthorize("@ss.hasPermi('system:search:edit')")
    @Log(title = "检索数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssistPdfSearchBase assistPdfSearchBase)
    {
        return toAjax(assistPdfSearchBaseService.updateAssistPdfSearchBase(assistPdfSearchBase));
    }

    /**
     * 删除检索数据
     */
    @PreAuthorize("@ss.hasPermi('system:search:remove')")
    @Log(title = "检索数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assistPdfSearchBaseService.deleteAssistPdfSearchBaseByIds(ids));
    }
}
